﻿using Microsoft.AspNetCore.Mvc;
using 项目备忘录.Models;

namespace 项目备忘录.Controllers
{
    public class EditController : Controller
    {
        public IActionResult Index(int id)
        {
            Project? project = Project.projects.Find(item => item.id == id);
            if (project != null)
            {
                ViewData["data"] = project;
            }
            return View();
        }
        [HttpPost]
        public IActionResult updateProject(Project p)
        {
            Project? project = Project.projects.Find(item => item.id == p.id);
            if (project != null)
            {
                project.projectName = p.projectName;
                project.country = p.country;
                project.province = p.province;
                project.desc = p.desc;
                project.person = p.person;
                project.manager = p.manager;
                project.managerTelNum = p.managerTelNum;
                project.department = p.department;
                project.date = p.date;
                project.status = p.status;
            }
            return RedirectToAction("Index", "Home");
        }
    }
}
